﻿using NHibernate;
using StructureMap;
using Yala.Core.Authentication;
using Yala.DataAccess.Common.Nhibernate.Repositories;
using Yala.Models.AuthProviders;
using Yala.Models.Items;
using Yala.Models.UserProfiles;
using Yala.Models.Users;
using Yala.Client.Web.MVC.Infrastructure.Membership;

namespace Yala.Client.Web.MVC.IocSetup {
    public static class Bootstrapper {
        public static IContainer ConfigureStructureMap() {
            ObjectFactory.Initialize(x => {
                x.For<IFormsAuthentication>().Use<AspNetFormsAuthentication>();
                x.For<ISession>().Use(s => MvcApplication.SessionFactory.GetCurrentSession());
                x.For<IAuthProvidersRepository>().Use<NhAuthProvidersRepository>();
                x.For<IUsersRepository>().Use<NhUsersRepository>();
                x.For<IItemsRepository>().Use<NhItemsRepository>();
                x.For<IUserProfilesRepository>().Use<NhUserProfilesRepository>();
                x.For<IMembership>().Use<OpenIdMembership>();
            });
            return ObjectFactory.Container;
        }
    }
}